<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-oa',
    'language' => 'zh-Cn',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'oa\controllers',
    'bootstrap' => ['log'],
    'components' => [
        'request' => [
            'enableCookieValidation' => false,
            'enableCsrfValidation'   => false,
            'csrfParam' => '_csrf-oa',
        ],
        'user' => [
            'identityClass' => 'oa\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-oa', 'httpOnly' => true],
            'on afterLogin' => function($event) {
                $user = $event->identity;
                $user->last_login_at = time();
                $user->save();
            },
        ],
        'session' => [
            'name' => 'tta-oa',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'assetManager' => [
            'appendTimestamp' => true,  //实测对性能有影响
            // 'linkAssets'      => true, // 刷新后就可以清除缓存
            // 'forceCopy'       => true,
            'bundles' => [
                'yii\web\JqueryAsset' => [
                    'class' => 'common\assets\JqueryAsset'
                ],
                'yii\bootstrap\BootstrapAsset' => [
                    'class' => 'common\assets\BootstrapAsset'
                ],
            ]
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                'tools'           => 'tool/index',
                'login'           => 'public/login',
                'send-verifycode' => 'public/sendVerifycode',
                'seekpassword'    => 'public/seekPassword',
                'logout'          => 'site/logout',
                'my'              => 'site/my',
                'upload'          => 'site/upload',
                'edit-password'   => 'site/editPassword',
                'refresh-menu'    => 'site/refreshMenu',
            ],
        ],
    ],
    'modules' => [
        'contract' => [
            'class' => 'oa\modules\contract\Module',
        ],
    ],
    'params' => $params,
];
